
var mongodb = require('./db')
var Schema = mongodb.mongoose.Schema


var productSchema = new Schema({
    name: {
        type:  String,
        required: true
    },
    category: {
        type:  String,
        required: true
    },
    categoryId: {
        type:  String,
        required: true
    },
    unit: {
        type:  String,
        required: true
    },
    total: {
        type: Number,
        default: 0
    },
    stock:{
        type: Number,
        default: 0
    },
    delivery:{
        type: Number,
        default: 0
    },
    remarks: {
        type: String,
        default: ''
    },
    created_time: {
        type: String,
        default: () => {
            return moment().utcOffset(8).format('YYYY-MM-DD HH:mm:ss')
        }
    },
    last_modified_time:{
        type: String,
        default: () => {
            return moment().utcOffset(8).format('YYYY-MM-DD HH:mm:ss')
        }
    }
})

module.exports = mongodb.mongoose.model('Product', productSchema)